#ifndef _AUDIO_FILTER_H_
#define _AUDIO_FILTER_H_

#include "audio_error.h"
#include "audio_element.h"

/**
 * @brief      Filter Configuration
 */
typedef struct {
    int type;                           /*filter type*/
    int channel;                        /*!< The number of channels for input stream */
    int out_rb_size;                    /*!< Size of output ringbuffer */
    int task_stack;                     /*!< Task stack size */
    int task_core;                      /*!< Task running in core (0 or 1) */
    int task_prio;                      /*!< Task priority (based on freeRTOS priority) */
} record_filter_cfg_t;

#define RECORD_FILTER_SET_TASK_STACK       (4 * 1024)
#define RECORD_FILTER_SET_TASK_CORE        (0)
#define RECORD_FILTER_SET_TASK_PRIO        (5)
#define RECORD_FILTER_SET_RINGBUFFER_SIZE  (16 * 1024)

#define DEFAULT_RECORD_FILTER_CONFIG() {                                         \
        .type = 0,                                                                \
        .channel = 1,                                                               \
        .out_rb_size = RECORD_FILTER_SET_RINGBUFFER_SIZE,                              \
        .task_stack = RECORD_FILTER_SET_TASK_STACK,                                    \
        .task_core = RECORD_FILTER_SET_TASK_CORE,                                      \
        .task_prio = RECORD_FILTER_SET_TASK_PRIO,                                      \
    }

typedef struct  {
        short   len;
        short   *databuf;
} rcdPackage_t;

/**
 * @brief      Set the number of channels of input audio stream
 *
 * @param      self       Audio element handle
 * @param      channels   the number of channels for input stream
 */
void record_filter_set_channel(audio_element_handle_t self, int channel);

/**
 * @brief      Set the type of filter
 *
 * @param      self       Audio element handle
 * @param      type     the set type of filter
 */
void record_filter_set_type(audio_element_handle_t self, int type);

/**
 * @brief      Get the type of filter
 *
 * @param      self       Audio element handle 
 * 
 * @return     the type of filter
 */
int record_filter_get_type(audio_element_handle_t self);

/**
 * @brief      Create an Audio Element handle to filter of input audio stream with band pass filter
 *
 * @param      config     the configuration
 * @return     the audio element handler
 */
audio_element_handle_t record_filter_init(record_filter_cfg_t *config);

#endif

